package com.dianjing.dianqun.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dianjing.dianqun.common.base.CrudService;
import com.dianjing.dianqun.dao.ContentLikeMapper;
import com.dianjing.dianqun.model.ContentLike;

/**
 * @date : 2017年11月3日
 * 
 * @author: baoyongtao
 * 
 * @see :
 * 
 */
@Service
@Transactional
public class ContentLikeService extends CrudService<ContentLikeMapper, ContentLike> {

	@Autowired
	private ContentLikeMapper contentLikeMapper;

	/**
	 * 查询用户是否点赞
	 * 
	 * @param userId
	 * @param contentId
	 * @return
	 */
	public ContentLike selectLikeByUser(Integer userId, Integer contentId) {
		return contentLikeMapper.selectLikeByUser(userId, contentId);
	}

	/**
	 * 查询文章点赞数
	 * @param contentId
	 * @return
	 */
	public Integer selectLikeByContentId(Integer contentId) {
		return contentLikeMapper.selectLikeByContentId(contentId);
	}

	@Transactional(readOnly=false)
	public void cancelLikeByContentId(Integer userId, Integer contentId) {
		contentLikeMapper.cancelLikeByContentId(userId,contentId);
		
	}

}
